#include "../include/cpuid.h" 
#include "../include/strings.h"
#include "../include/getnum.h"
void
cpuidFab(int ebx, int ecx, int edx){
  print("ID FABRICANTE: ");
  int a, i;
  for(i=0; i<4; i++){
    a=(ebx>>i*8)&0xff;
    putc(a,1);
  }
  for(i=0; i<4; i++){
    a=(ecx>>i*8)&0xff;
    putc(a,1);
  }
  for(i=0; i<4; i++){
    a=(edx>>i*8)&0xff;
    putc(a,1);
  }
  print(".\n\n");
  return;
}

void
cpuidBraSt(int eax, int ebx, int ecx, int edx){
  int a, i;
  for(i=0; i<4; i++){
    a=(eax>>i*8)&0xff;
    putc(a,1);
  }
  for(i=0; i<4; i++){
    a=(ebx>>i*8)&0xff;
    putc(a,1);
  }
  for(i=0; i<4; i++){
    a=(edx>>i*8)&0xff;
    putc(a,1);
  }
    for(i=0; i<4; i++){
    a=(ecx>>i*8)&0xff;
    putc(a,1);
  }
  return;
}

void
cpuidBra(int ebx){
  int a;
  a=ebx&0xff;
  print("\n");
  if(a!=0){
    switch(a){
      case(0x0):break;
      case(0x1):print("Intel  Celeron  processor");break;
      case(0x2):print("Intel  PentiumIII  processor");break;
      case(0x3):print("Intel  PentiumIII  XeonTM processor");break;
      case(0x4):print("Intel  PentiumIII  processor");break;
      case(0x5):break;
      case(0x6):print("Mobile Intel Pentium III Processor-M");break;
      case(0x7):print("Mobile Intel Celeron processor");break;
      case(0x8):
      case(0x9):print("Intel Pentium 4 processor");break;
      case(0xA):print("Intel Celeron  processor");break;
      case(0xB):print("Intel XeonTM processor");break;
      case(0xC):print("Intel XeonTM processor MP");break;
      case(0xD):break;
      case(0xE):print("Mobile Intel Pentium 4 processor");break;
      case(0xF):print("Mobile Intel Celeron processor");break;
    }
    print("\n");
  }
  
}


void
cpuidPS(int edx){
	int i;
	int sop=0;
	if(edx != 0){
		print("Features soportadas: \n");
		for(i=0; i <30;i++){
			if((edx>>i)&0x1){
				switch(i){
			case(0):print("(1)*FPU.       ");break;
			case(1):print("(2)*VME.       ");break;
			case(2):print("(3)*DE.        ");break;
			case(3):print("(4)*PSE.       ");break;
			case(4):print("(5)*TSC.       ");break;
			case(5):print("(6)*MSR.       ");break;
			case(6):print("(7)*PAE.       ");break;
			case(7):print("(8)*MCE.       ");break;
			case(8):print("(9)*CX8.       ");break;
			case(9):print("(10)*APIC.      ");break;			
			case(10):break;
			case(11):print("(11)*SEP.      ");break;
			case(12):print("(12)*MTRR.     ");break;
			case(13):print("(13)*PGE.      ");break;
			case(14):print("(14)*MCA.      ");break;
			case(15):print("(15)*CMOV.     ");break;
			case(16):print("(16)*PAT.      ");break;
			case(17):print("(17)*PSE-36.   ");break;
			case(18):print("(18)*PSN.      ");break;
			case(19):print("(19)*CLFSH.    ");break;
			case(20):break;
			case(21):print("(21)*DS.       ");break;
			case(22):print("(22)*ACPI.     ");break;
			case(23):print("(23)*MMX.      ");break;
			case(24):print("(24)*FXSR.     ");break;
			case(25):print("(25)*SSE.      ");break;
			case(26):print("(26)*SSE2.     ");break;
			case(27):print("(27)*SS.       ");break;
			case(28):print("(28)*HTT.      ");break;
			case(29):print("(29)*TMS.      ");break;      
				}
			if(sop++ == 3){
				print("\n");
				sop=0;
			}
			}    
		}
		print("\n");
	}
  
  
  
 return; 
}

void
infoFeature(void)
{		int i;
		do{
			print("Ingrese feature(1-29):");
			i=getint();
		}
		while(i<1 || i>29);
    
		switch(i){
			case(1):print("*FPU: Floating-point unit on-chip\n");break;
			case(2):print("*VME: Virtual Mode Extension\n");break;
			case(3):print("*DE: Debugging Extension\n");break;
			case(4):print("*PSE: Page Size Extension\n");break;
			case(5):print("*TSC: Time Stramp Counter\n");break;
			case(6):print("*MSR: Model Specific Registers\n");break;
			case(7):print("*PAE: Physical Address Extension\n");break;
			case(8):print("*MCE: Machine Check Extension\n");break;
			case(9):print("*CX8: CMPXCHG8 Intruction Supported\n");break;				case(10):print("*APIC:  On-chip APIC Hardware Supported\n");break;
			case(11):print("*SEP:  Fast System Call\n");break;
			case(12):print("*MTRR:  Memory Type Range Registers\n");break;
			case(13):print("*PGE:  Page Global Enable\n");break;
			case(14):print("*MCA:  Mechine Check Architecture\n");break;
			case(15):print("*CMOV:  Conditional Move Instruccion Suported\n");break;
			case(16):print("*PAT:  Page Attribute Table\n");break;
			case(17):print("*PSE-36: 36-bit Page size Extension\n");break;
			case(18):print("*PSN: Processor serial number is present and enabled\n");break;
			case(19):print("*CLFSH:  CLFLUSH Instruction suported\n");break;
			case(20):break;
			case(21):print("*DS:  Debug Store\n");break;
			case(22):print("*ACPI:  Thermal Monitor and Software Controlled Clock Facilities supported\n");break;
			case(23):print("*MMX:  Intel Arquitecture MMZ technology supported\n");break;
			case(24):print("*FXSR:  Fast floating point save and store\n");break;
			case(25):print("*SSE:  Streming SIMD Extension supported\n");break;
			case(26):print("*SSE2:  Streaming SIMD Extension 2\n");break;
			case(27):print("*SS:  Self-Snoop\n");break;
			case(28):print("*HTT:  Hyper-Threading Technology\n");break;
			case(29):print("*TM:  Thermal Monitor suported\n \n");break;
		}
		print("\n");
}
